package com.demo.mybaits.db;

import javax.sql.DataSource;

public class DataSourceProvider {
	private static DataSourceStrategy dataSourceStrategy;

	private static DataSource dataSource;

	public static void context(DataSourceStrategy strategy) {
		dataSourceStrategy = strategy;
	}

	public static DataSource init() {
		context(new MysqlDataSource());
		dataSource = dataSourceStrategy.getDataSource();

		return dataSource;
	}

	public static DataSource init(String dbType) {
		switch (dbType) {
		case "mysql":
			context(new MysqlDataSource());
			break;
		default:
			context(new MysqlDataSource());
			break;
		}
		dataSource = dataSourceStrategy.getDataSource();

		return dataSource;
	}
}
